package base.day24;

import java.io.*;

public class MyCharacterStream11 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {

        method1();

        method2();
    }

    private static void method1() throws IOException {
        User user=new User("zhangsan","11111");
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("C:\\Users\\SuperJohn\\Desktop\\abc.txt"));
        oos.writeObject(user);
        oos.close();
    }

    private static void method2() throws IOException, ClassNotFoundException {
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("C:\\Users\\SuperJohn\\Desktop\\abc.txt"));
        User o = (User) ois.readObject();
        System.out.println(o);
        ois.close();
    }
}
